package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.EngineerLevel;
import com.shrcl.engineerprocess.domain.EngineerLevelDAO;
import com.shrcl.engineerprocess.domain.EngineerLevelSalary;
import com.shrcl.engineerprocess.domain.impl.EngineerLevelImpl;
import edu.fudan.mylang.pf.BaseDAOService;
import edu.fudan.mylang.pf.IGenericQuery;
import java.util.Collection;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.springframework.stereotype.Service;

@Service("com.shrcl.engineerprocess.domain.EngineerLevelDAO")
public class EngineerLevelDAOImpl extends BaseDAOService<EngineerLevel> implements EngineerLevelDAO {
  public EngineerLevel create(final Procedure1<? super EngineerLevel> updater) {EngineerLevel engineerLevel=EngineerLevelImpl.create(getObjectFactory());
    final Procedure1<EngineerLevel> _function = new Procedure1<EngineerLevel>() {
        public void apply(final EngineerLevel it) {
          updater.apply(it);
          it.checkValid();
        }
      };
    EngineerLevel _doubleArrow = ObjectExtensions.<EngineerLevel>operator_doubleArrow(engineerLevel, _function);
    return _doubleArrow;
  }
  
  public void delete(final EngineerLevel engineerLevel) {
    engineerLevel.setIsActive(Boolean.valueOf(false));
  }
  
  public Collection<EngineerLevel> getAllLevels() {IGenericQuery<EngineerLevel> query=getObjectFactory().createGenericQuery(EngineerLevel.class,"select e from com.shrcl.engineerprocess.domain.impl.EngineerLevelImpl as e   where  e.active = 1      ");
    Collection<EngineerLevel> _list = query.list();
    return _list;
  }
  
  public EngineerLevelSalary getEngineerLevelSalary(final EngineerLevel engineerLevel) {
    IGenericQuery<EngineerLevelSalary> query=getObjectFactory().createGenericQuery(EngineerLevelSalary.class,"select e from com.shrcl.engineerprocess.domain.impl.EngineerLevelSalaryImpl as e   where ((e.level) = (:engineerLevel)) and  e.active = 1      ").setParameter("engineerLevel",engineerLevel);
    EngineerLevelSalary _uniqueResult = query.uniqueResult();
    return _uniqueResult;
  }
}
